<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class service extends CI_Controller {

	function __construct()
	{
		parent::__construct();
	}

	function index()
	{
		
		
	}
	function get_district($province_id,$current_id=0,$first =1)
	{
			$this->db->where("province_id",$province_id);
	 		$rows = $this->db->get("amphur")->result_array();
	 		
	 		if($first)
	 		{
	 			echo '<option value="0">โปรดเลือก</option>';
	 		}
	 		foreach($rows as $row)
	 		{
	 			$changed ="";
	 			if($current_id ==$row["amphur_id"])
	 			{
	 			 $changed = 'selected="selected"';
	 			}	
	 			echo '<option '.$changed.' value="'.$row["amphur_id"].'">'.$row["amphur_name"].'</otption>';
	 		}
	 
	}
	function get_sub_district($parent_id=0,$current_id=0,$first =1)
	{
		$this->db->where("amphur_id",$parent_id);
	 		$rows = $this->db->get("district")->result_array();
			if($first)
	 		{
	 			echo '<option value="0">โปรดเลือก</option>';
	 		}
	 		foreach($rows as $row)
	 		{
	 			$changed ="";
	 			if($current_id ==$row["district_id"])
	 			{
	 			 $changed = 'selected="selected"';
	 			}	
	 			echo '<option '.$changed.' value="'.$row["district_id"].'">'.$row["district_name"].'</otption>';
	 		}
	}
}